<template>
  <h3>name: {{name}}</h3>
  <h3>age: {{age}}</h3>
  <button @click="handler">handler</button>
  <p>{{msg}}--{{num}}</p>
  <button @click="add">add</button>
</template>

<script>
// import {h} from 'vue'
export default {
  name: 'App',
  // 此时setup中的数据并不响应式数据
  data(){
    return {
      msg:'hello world',
      num:1
    }
  },
  methods:{
    add(){
      this.num++;
    }
  },
  setup(){
    //数据
    let name="张三";
    let age=18;

    //方法
    function handler(){
      console.log("我是"+name);
      name="胡歌";
      age=30;
      console.log(name,age);
    }

    return {
      name,
      age,
      handler
    }

    // return ()=>h('h1','胡歌')
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* text-align: center; */
  color: #2c3e50;
  margin-top: 60px;
}
</style>
